package com.thouiot.modbus.config;

/**
 * @description modbus master/slave类型枚举
 * @author wangkai
 * @date 2025/04/10 16:30
 */
public enum ModbusTypeEnum {
    TCP("tcp"),
    UDP("udp"),
    RTU("rtu"),
    ASCII("ascii");

    private String type;

    ModbusTypeEnum(String type) {
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public static ModbusTypeEnum getModbusTypeEnum(String type) {
        for (ModbusTypeEnum masterTypeEnum : ModbusTypeEnum.values()) {
            if (masterTypeEnum.getType().equals(type)) {
                return masterTypeEnum;
            }
        }
        return null;
    }
}
